package org.inspursc.s0517.health.common.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.inspursc.s0517.health.common.dao.SysGroupDao;
import org.inspursc.s0517.health.common.entity.SysGroup;
import org.inspursc.s0517.health.common.service.SysGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
@Slf4j
public class SysGroupServiceImpl implements SysGroupService {

    @Autowired
    private SysGroupDao groupDao;

    @Override
    public SysGroup save(SysGroup group) {
        return groupDao.save(group);
    }

    @Override
    public SysGroup findById(Integer groupId) {
        return groupDao.getOne(groupId);
    }

    @Override
    public List<SysGroup> findAll() {
        return groupDao.findAll();
    }

    @Override
    @Transactional
    public boolean deleteById(Integer groupId) {
        try {
            groupDao.deleteById(groupId);
            return true;
        } catch (Exception e) {
            log.error("【删除失败】", e.getMessage());
            return false;
        }
    }
}
